import 'package:flutter/material.dart';
import 'package:toastification/toastification.dart';
import 'package:word_range_client/config/GlobalThemData.dart';


// 通知颜色就先不按组题色了

class Toastification {
  BuildContext? context;
  Toastification({
    required BuildContext? context,
  });

  void showSuccess(String msg){
    toastification.show(
      context: context,
      style: ToastificationStyle.simple,
      type: ToastificationType.success,
      title: Text(msg),
      icon: const Icon(Icons.message),
      alignment: Alignment.topCenter,
      backgroundColor: const Color(0xff469bcf),
      foregroundColor: GlobalThemData.lightColorScheme.background,
      autoCloseDuration: const Duration(seconds: 3),
    );
  }

  void showInfo(String msg){
    toastification.show(
      context: context,
      style: ToastificationStyle.simple,
      type: ToastificationType.info,
      title: Text(msg),
      icon: const Icon(Icons.message),
      alignment: Alignment.topCenter,
      autoCloseDuration: const Duration(seconds: 2),
    );
  }

  void showWarning(String msg){
    toastification.show(
      context: context,
      style: ToastificationStyle.simple,
      type: ToastificationType.warning,
      title: Text(msg),
      icon: const Icon(Icons.warning),
      alignment: Alignment.topCenter,
      backgroundColor: const Color(0xffd6934f),
      foregroundColor: GlobalThemData.lightColorScheme.background,
      autoCloseDuration: const Duration(seconds: 2),
    );
  }

  void showError(String msg){
    toastification.show(
      context: context,
      style: ToastificationStyle.simple,
      type: ToastificationType.error,
      title: Text(msg),
      icon: const Icon(Icons.warning),
      alignment: Alignment.topCenter,
      backgroundColor: GlobalThemData.lightColorScheme.error,
      foregroundColor: GlobalThemData.lightColorScheme.background,
      autoCloseDuration: const Duration(seconds: 3),
    );
  }
}